Fixed the yes/no prompt in verdi computer delete#6624
Fixed the yes/no prompt in verdi computer delete#6624agoscinski merged 3 commits intoaiidateam:mainfrom
Conversation
|
I am sorry for the back and forth but reading now the conversation in issue #6422 more carefully and looking at the deletion in other parts of the code. We can change it to |
ce1ff59 to
ccc2832
Compare
1225c23 to
1f5aea4
Compare
Ohk @agoscinski I will do '[y/N]' |
|
@agoscinski |
|
No worries I take over. It should now work. |
|
I want to contribute more to organisation so I want to install the codebase locally |
e3f8bef to
a33cfb2
Compare
|
Sure can you contact me on https://aiida.discourse.group ? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6624 +/- ##
==========================================
+ Coverage 78.58% 78.59% +0.01%
==========================================
Files 567 567
Lines 43086 43087 +1
==========================================
+ Hits 33856 33861 +5
+ Misses 9230 9226 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thank you sir |
khsrali
left a comment
There was a problem hiding this comment.
Thanks a lot @Krishnabhujade and @agoscinski ,
Some minor comments
| def test_computer_delete_nonexisting_computer(self): | ||
| """Test if `verdi computer delete` command works correctly for a nonexisting computer""" | ||
| # See if the command complains about not getting an nonexisting computer | ||
| self.cli_runner(computer_delete, ['computer_that_does_not_exist'], raises=True) |
There was a problem hiding this comment.
Please check explicitly if the raise is due to NotExistent.
Also please pass user_input=y I know here it might not matter because the query comes before click.confirm,
however, later if someone changes the order of the logic in the code then test might silently pass..
Better to be precise.
Thanks
There was a problem hiding this comment.
We cannot check the actual exception at the CLI level, we only get a system exit. I added assert for the error message that relate to that exception.
| orm.Computer.collection.get(label=label) | ||
| # Safety check in case of --dry-run | ||
| options = [label, '--dry-run'] | ||
| self.cli_runner(computer_delete, options) |
There was a problem hiding this comment.
| self.cli_runner(computer_delete, options) | |
| self.cli_runner(computer_delete, options, user_input="y") |
| # Setup a computer to delete during the test | ||
| label = 'computer_for_test_label' | ||
| orm.Computer( | ||
| def test_computer_delete_existing_computer(self): |
There was a problem hiding this comment.
I found this test name kinda misleading for it's purpose
| def test_computer_delete_existing_computer(self): | |
| def test_computer_do_not_delete(self): |
There was a problem hiding this comment.
named it test_computer_delete_existing_computer_not_deleted do be consistent with the test name of the other one
85d7c21 to
6c69993
Compare
khsrali
left a comment
There was a problem hiding this comment.
Thanks @agoscinski, all good!
6c69993 to
e14a2bc
Compare
| orm.load_code(c_label) | ||
|
|
||
| def test_computer_delete(self): | ||
| """Test if 'verdi computer delete' command works""" |
There was a problem hiding this comment.
I don't understand why this test is deleted.
Where do we actually check if the the command would function, when deleting a computer that has no associated nodes?
There was a problem hiding this comment.
true the diff looks weird now. I just redo this PR when I have time
There was a problem hiding this comment.
yes this test exists I restructured the tests a bit, made them more granular. I restructured the tests test_computer_delete and test_computer_delete_with_nodes to more granular test cases test_computer_delete_existing_computer_successful, test_computer_delete_existing_computer_not_deleted and test_computer_delete_nonexisting_computer
There was a problem hiding this comment.
Ok still I don't see a test that would delete a computer without associated nodes.
Like this:
def test_computer_delete_no_associated nodes(self):
orm.Computer(..).store().configure()
self.cli_runner(computer_delete, [label])
with pytest.raises(NotExistent):
orm.Computer.collection.get(label=label)
a674a64 to
35f14e3
Compare
a48331c to
030627a
Compare
khsrali
left a comment
There was a problem hiding this comment.
Alex we need a test like this to make sure not having associated nodes will not prompt for an input and can function as before:
def test_computer_delete_no_associated nodes(self):
orm.Computer(..).store().configure()
self.cli_runner(computer_delete, [label])
with pytest.raises(NotExistent):
orm.Computer.collection.get(label=label)
| # Ensures that 'yes' works for backwards compatibility, see issue #6422 | ||
| @pytest.mark.parametrize('user_input', ['y', 'yes']) | ||
| def test_computer_delete_existing_computer_successful(self, user_input): | ||
| """Test if `verdi computer delete` successfully deletes when applied on an existing computer.""" |
There was a problem hiding this comment.
| """Test if `verdi computer delete` successfully deletes when applied on an existing computer.""" | |
| """Test if `verdi computer delete` successfully deletes when applied on an existing computer, which has associated nodes.""" |
There was a problem hiding this comment.
There is no difference if you delete a node that is associated to something
$ node delete 8
Report: 1 Node(s) marked for deletion
Warning: YOU ARE ABOUT TO DELETE 1 NODES! THIS CANNOT BE UNDONE!
| orm.load_code(c_label) | ||
|
|
||
| def test_computer_delete(self): | ||
| """Test if 'verdi computer delete' command works""" |
There was a problem hiding this comment.
Ok still I don't see a test that would delete a computer without associated nodes.
Like this:
def test_computer_delete_no_associated nodes(self):
orm.Computer(..).store().configure()
self.cli_runner(computer_delete, [label])
with pytest.raises(NotExistent):
orm.Computer.collection.get(label=label)
048a9f0 to
699f27f
Compare
The yes/no prompt of `verdi computer delete` is the only prompt in the CLI that does not accept 'y' as valid answer but only 'yes'. This has been aligned with the other prompts to also support 'y'. Restructure the tests `test_computer_delete` and `test_computer_delete_with_nodes` to more granular test cases `test_computer_delete_existing_computer_successful`, `test_computer_delete_existing_computer_not_deleted` and `test_computer_delete_nonexisting_computer` Cleanup names in tests.
…e associated to the computer
The mock timeout is reached in CI so we increase it.
699f27f to
183465f
Compare
|
What's happening here after my approval 👀 |
|
Everything is fine here, please Sir review my next PR. |
This PR fixes the "yes/no" prompt in verdi computer delete
Fixes #6422